import ToolBar from "@/components/ViewComponents/Toolbar";
import { useTranslation } from "react-i18next";
import { BasicColumn, BasicTable, FormSchema, useRender, useTable } from "@/components/Table";
import { patientOrdersPage } from "@/api/MedicalExamination";

const index = () => {
	const { t } = useTranslation();
	const searchFormSchema: FormSchema[] = [
		{
			label: t("kevin_ui.from_date"),
			field: "tu_ngay",
			component: "DatePicker"
		},
		{
			label: t("kevin_ui.to"),
			field: "den",
			component: "DatePicker"
		},
		{
			label: t("kevin_ui.type"),
			field: "type",
			component: "Select"
		},
		{
			label: t("felix_ui.dept_name"),
			field: "department",
			component: "Select"
		},
		{
			label: t("kevin_ui.pat_subject"),
			field: "subject",
			component: "Select"
		},
		{
			label: t("kevin_ui.doctor"),
			field: "doctorName",
			component: "Select"
		}
	];
	const columns: BasicColumn[] = [
		{
			title: t("felix_ui.patient_ID"),
			dataIndex: "patientId"
		},
		{
			title: t("felix_ui.orderType"),
			dataIndex: "orderType",
			render: value => useRender.renderDictText(value, "order_type")
		},
		{
			title: t("felix_ui.orderAmount"),
			dataIndex: "totalPrice"
		},
		{
			title: t("felix_ui.doctorName"),
			dataIndex: "doctorName"
		},
		{
			title: t("felix_ui.status"),
			dataIndex: "status",
			render: value => useRender.renderDict(value, "order_status")
		}
	];

	const [registerTable] = useTable({
		api: patientOrdersPage,
		columns,
		useSearchForm: true,
		formConfig: {
			labelWidth: 120,
			schemas: searchFormSchema,
			showActionButtonGroup: true,
			baseColProps: { span: 6 }
		}
	});

	return (
		<div className="page">
			<div className="page-content block">
				<BasicTable register={registerTable}></BasicTable>
			</div>
			<ToolBar btnList={[{ key: "print" }]}></ToolBar>
		</div>
	);
};
export default index;
